//
//  WDRootZhuangBeiViewController.m
//  qiJi
//
//  Created by 凤利史 on 2018/3/29.
//  Copyright © 2018年 sunrose. All rights reserved.
//

#import "WDRootZhuangBeiViewController.h"
#import "ZJScrollPageView.h"
#import "WDRootZhuangBei1ViewController.h"
#import "WDRootZhuangBei2ViewController.h"
#import "WDRootZhuangBei3ViewController.h"
@interface WDRootZhuangBeiViewController ()<ZJScrollPageViewDelegate>
@property(strong, nonatomic)NSArray<NSString *> *titles;
@property(strong, nonatomic)NSArray<UIViewController<ZJScrollPageViewChildVcDelegate> *> *childVcs;

@end

@implementation WDRootZhuangBeiViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"装备";
    self.view.backgroundColor = getColor(@"FAFAFA");
    
    [self creationView];
    
    // Do any additional setup after loading the view.
}

- (void)creationView{
    
    //必要的设置, 如果没有设置可能导致内容显示不正常
    self.automaticallyAdjustsScrollViewInsets = NO;
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    style.scrollTitle = YES;
    style.autoAdjustTitlesWidth = YES;
    style.adjustCoverOrLineWidth = YES;
    style.selectedTitleColor = [UIColor colorWithRed:51 / 255.0f green:51 / 255.0f blue:51 / 255.0f alpha:1];
    style.scrollLineColor = [UIColor colorWithRed:255 / 255.0f green:209 / 255.0f blue:0 / 255.0f alpha:1];
    style.segmentHeight = 40;
    self.titles = @[@"整车装备",
                    @"整车装备",
                    @"整车装备",
                    ].mutableCopy;
    //self.childVcs = [self setupChildVc];
    
    // 初始化
    ZJScrollPageView *scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64.0) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    [scrollPageView setSelectedIndex:self.index animated:YES];
    scrollPageView.contentView.scrollView.scrollEnabled = YES;
    [self.view addSubview:scrollPageView];
}

#pragma mark ----------------ZJScrollPageViewDelegate---------------------
- (NSInteger)numberOfChildViewControllers {
    
    return self.titles.count;
    
}
- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    
    WDRootZhuangBei1ViewController <ZJScrollPageViewChildVcDelegate> *childVc = (WDRootZhuangBei1ViewController *)reuseViewController;
    
    if (!childVc) {
        
        childVc = [[WDRootZhuangBei1ViewController alloc] init];
        
        
//        childVc.orderStatus = index;
//
//
//        NSLog(@"MMMMMMMMMMMMMM%ld", (long)index);
        
        
    }
    
    return childVc;
}




//- (NSArray *)setupChildVc {
//
//    WDRootZhuangBei1ViewController *vc1 = [WDRootZhuangBei1ViewController new];
//    WDRootZhuangBei2ViewController *vc2 = [WDRootZhuangBei2ViewController new];
//    WDRootZhuangBei3ViewController *vc3 = [WDRootZhuangBei3ViewController new];
//
//
//
//    NSArray *childVcs = [NSArray arrayWithObjects:vc1, vc2, vc3, nil];
//    return childVcs;
//}
//
//- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
//
//    UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
//
//    if (!childVc) {
//        childVc = self.childVcs[index];
//    }
//
//
//
//    return childVc;
//}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
